cc.Class({
    extends: cc.Component,

    properties: {
        Type : 0,
        progress:cc.Sprite,
        cdtime: 20,
    },
    start () {
      this.startCD = false;
      this.timeduring = 0;
      this.node.on('click',function () {
          if(this.startCD) return;
          cc.find('Canvas/alert').active = true;
          cc.find('Canvas/alert').getComponent('alert').init(this.Type);
      },this);
        if(this.Type === 0){
            cc.find('Canvas').on('speedMeat',function(){
                this.startCD = true;
                this.progress.fillRange = -1;
            },this);
        }else if(this.Type === 1){
            cc.find('Canvas').on('speedDrink',function(){
                this.startCD = true;
                this.progress.fillRange = -1;
            },this);
        }else{
            cc.find('Canvas').on('doubleDiamond',function(){
                this.startCD = true;
                this.progress.fillRange = -1;
            },this);
        }
    },
    update (dt) {
        if(!this.startCD)  return;
        this.timeduring += dt;
        this.progress.fillRange = -1 + this.timeduring / this.cdtime;
        if(this.progress.fillRange >= 0){
            this.progress.fillRange = 0;
            this.startCD = false;
            this.timeduring = 0;
            if(this.Type === 0){
                cc.speedMeat = 1;
            }else if(this.Type === 1){
                cc.speedDrink = 1;
            }else{
                cc.doubleDiamond = 1;
            }
        }
    },


});
